/*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Teunis van Beelen
*
* teuniz@gmail.com
*
***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
***************************************************************************
*
* This version of GPL is at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
*
***************************************************************************
*/

/* last revision: Januari 31, 2014 */

/* For more info and how to use this libray, visit: http://www.teuniz.net/RS-232/ */


#ifndef rs232_INCLUDED
#define rs232_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <string.h>

enum parity_mode
{
    none,
    even,
    odd,
};

enum data_bits
{
    db5,
    db6,
    db7,
    db8,
    db9,
};

enum stop_bits
{
    sb1,
    sb2,
};

#ifdef __linux__
    #include <termios.h>
    #include <sys/ioctl.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <limits.h>
    #define  DLL_EXPORT
#else
    #include <windows.h>
    #ifndef WIN32_LEAN_AND_MEAN
        #define WIN32_LEAN_AND_MEAN
    #endif
    #define  DLL_EXPORT _declspec(dllexport)
#endif

DLL_EXPORT int RS232_OpenComport(int, int);
DLL_EXPORT int RS232_PollComport(int, unsigned char *, int);
DLL_EXPORT int RS232_SendByte(int, unsigned char);
DLL_EXPORT int RS232_SendBuf(int, unsigned char *, int);
DLL_EXPORT void RS232_CloseComport(int);
DLL_EXPORT void RS232_cputs(int, const char *);
DLL_EXPORT int RS232_IsDCDEnabled(int);
DLL_EXPORT int RS232_IsCTSEnabled(int);
DLL_EXPORT int RS232_IsDSREnabled(int);
DLL_EXPORT void RS232_enableDTR(int);
DLL_EXPORT void RS232_disableDTR(int);
DLL_EXPORT void RS232_enableRTS(int);
DLL_EXPORT void RS232_disableRTS(int);
DLL_EXPORT void RS232_SetAttributes(enum parity_mode,enum data_bits,enum stop_bits);
DLL_EXPORT void RS232_FlushBuffer(int);


#ifdef __cplusplus
} /* extern "C" */
#endif

#endif


